package com.ruoyi.system.webcrawler;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class CrawlResult {
    private boolean success;
    private String message;
    private int totalPages;
    private int extractedItems;
    private long executionTime;
    private List<Map<String, String>> data;
    private List<String> errors;

    public CrawlResult() {
        this.data = new ArrayList<>();
        this.errors = new ArrayList<>();
    }

    // 成功结果构造器
    public static CrawlResult success(String message) {
        CrawlResult result = new CrawlResult();
        result.setSuccess(true);
        result.setMessage(message);
        return result;
    }

    // 失败结果构造器
    public static CrawlResult error(String message) {
        CrawlResult result = new CrawlResult();
        result.setSuccess(false);
        result.setMessage(message);
        return result;
    }

    // getter and setter methods
    public boolean isSuccess() { return success; }
    public void setSuccess(boolean success) { this.success = success; }

    public String getMessage() { return message; }
    public void setMessage(String message) { this.message = message; }

    public int getTotalPages() { return totalPages; }
    public void setTotalPages(int totalPages) { this.totalPages = totalPages; }

    public int getExtractedItems() { return extractedItems; }
    public void setExtractedItems(int extractedItems) { this.extractedItems = extractedItems; }

    public long getExecutionTime() { return executionTime; }
    public void setExecutionTime(long executionTime) { this.executionTime = executionTime; }

    public List<Map<String, String>> getData() { return data; }
    public void setData(List<Map<String, String>> data) { this.data = data; }

    public List<String> getErrors() { return errors; }
    public void setErrors(List<String> errors) { this.errors = errors; }

    public void addData(Map<String, String> item) {
        this.data.add(item);
    }

    public void addError(String error) {
        this.errors.add(error);
    }
}
